//
//  WSJSportDataView.m
//  RunningMan
//
//  Created by dllo on 16/5/21.
//  Copyright © 2016年 WSJ. All rights reserved.
//

#import "WSJSportDataView.h"
#define W self.frame.size.width
#define H self.frame.size.height


@interface WSJSportDataView ()

@property(nonatomic, retain) UIImageView *backImageView;
@property(nonatomic, retain) UILabel *timeLength;
@property(nonatomic, retain) UILabel *distance;
@property(nonatomic, retain) UILabel *speed;

@end

@implementation WSJSportDataView
-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self addSubview];
   
    }
    return self;
}

-(void)addSubview{
    
    self.backImageView = [[UIImageView alloc] init];
    self.backImageView.image = [UIImage imageNamed:@"000.jpg"];
    self.backImageView.userInteractionEnabled = YES;
    [self addSubview:self.backImageView];
    
    
    UILabel *timeLabel = [[UILabel alloc] init];
    timeLabel.text = @"00:00:00";
    timeLabel.textAlignment = 1;
    timeLabel.textColor = [UIColor redColor];
    timeLabel.font = [UIFont fontWithName:@"ArialRoundedMTBold" size:50];
    [self.backImageView addSubview:timeLabel];
    self.timeLabel = timeLabel;
    
    UILabel *timeLength = [[UILabel alloc] init];
    timeLength.textAlignment = 1;
    timeLength.text = @"时长";
    timeLength.textColor = [UIColor whiteColor];
    [self.backImageView addSubview:timeLength];
    self.timeLength = timeLength;
    
    //-------
    UILabel *distanceLabel = [[UILabel alloc] init];
    distanceLabel.textAlignment = 1;
    distanceLabel.text = @"0.00";
    distanceLabel.textColor = [UIColor greenColor];
    distanceLabel.font = [UIFont systemFontOfSize:40];
    [self.backImageView addSubview:distanceLabel];
    self.distanceLabel = distanceLabel;
    
    UILabel *distance = [[UILabel alloc] init];
    distance.textAlignment = 1;
    distance.text = @"距离 ( 公里 )";
    distance.textColor = [UIColor whiteColor];
    [self addSubview:distance];
    self.distance = distance;
    
    //-----
    UILabel *speedLabel = [[UILabel alloc] init];
    speedLabel.textAlignment = 1;
    speedLabel.text = @"0.00";
    speedLabel.font = [UIFont systemFontOfSize:40];
    speedLabel.textColor = [UIColor greenColor];
    [self.backImageView addSubview:speedLabel];
    self.speedLabel = speedLabel;
    
    UILabel *speed = [[UILabel alloc] init];
    speed.textAlignment = 1;
    speed.text = @"速度 ( m / s )";
    speed.textColor = [UIColor whiteColor];
    [self.backImageView addSubview:speed];
    self.speed = speed;
    
    

    self.stopButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.stopButton setTitle:@"暂停" forState:UIControlStateNormal];
    self.stopButton.backgroundColor = [UIColor greenColor];
    self.stopButton.layer.cornerRadius = 40;
    self.stopButton.layer.masksToBounds = YES;
    self.stopButton.titleLabel.font = [UIFont systemFontOfSize:25];
    [self.backImageView addSubview:self.stopButton];
   // self.stopButton.hidden = YES;
    
    self.startButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.startButton setTitle:@"继续" forState:UIControlStateNormal];
    self.startButton.backgroundColor = [UIColor greenColor];
    self.startButton.layer.cornerRadius = 40;
    self.startButton.layer.masksToBounds = YES;
    self.startButton.titleLabel.font = [UIFont systemFontOfSize:25];
    [self.backImageView addSubview:self.startButton];
    self.startButton.hidden = YES;
    
    self.endButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.endButton setTitle:@"结束" forState:UIControlStateNormal];
    self.endButton.backgroundColor = [UIColor redColor];
    self.endButton.layer.cornerRadius = 40;
    self.endButton.layer.masksToBounds = YES;
    self.endButton.titleLabel.font = [UIFont systemFontOfSize:25];
    [self.backImageView addSubview:self.endButton];
    self.endButton.hidden = YES;
    
    self.lockButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.lockButton setBackgroundImage:[UIImage imageNamed:@"lock.png"] forState:UIControlStateNormal];
    [self.backImageView addSubview:self.lockButton];
    
    
}

-(void)layoutSubviews{
    [super layoutSubviews];
    
    self.backImageView.frame = CGRectMake(0, 0, W, H);
    
    self.timeLabel.frame = CGRectMake(0,30  , W, 50);
    self.timeLength.frame = CGRectMake(0, 80, W, 30);
    self.distanceLabel.frame = CGRectMake(0, 130, W / 2, 50);
    self.distance.frame = CGRectMake(0, 180, W / 2, 30);
    self.speedLabel.frame = CGRectMake(W / 2, 130, W / 2, 50);
    self.speed.frame = CGRectMake(W / 2, 180, 200, 30);
    
    self.stopButton.frame = CGRectMake(W / 2 - 40 , 370, 80, 80);
    self.startButton. frame = CGRectMake(W / 2 - 130, 370, 80, 80);
    self.endButton.frame = CGRectMake(W / 2 + 50, 370, 80, 80);
    
    self.lockButton.frame = CGRectMake(W / 2 - 20, H - 60, 40, 40);
    
    

}



@end
